<%@ page import="com.tlb.ejb.*,com.tlb.dto.*,com.tlb.web.*,java.util.*" %>
<%


            String threadId = request.getParameter("threadId");
            String postId = request.getParameter("postId");
            String treeId = request.getParameter("treeId");
            String x = request.getParameter("x");


            if (threadId == null || threadId.trim().equals("")) {
                threadId = "0";
            }

            if (postId == null || postId.trim().equals("")) {
                postId = "0";
            }

            if (treeId == null || treeId.trim().equals("")) {
                treeId = "0";
            }

            if (x == null || x.trim().equals("")) {
                x = "0";
            }

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>Big<%=Util.getUtil().getBoard(request) == Util.BCB ? "College" : "Law"%>Board.com</title>
        <link rel="stylesheet" type="text/css" href="ext/tlbStyle.css" />
        <link rel="shortcut icon" href="ext/c_sailboat.gif">
        <script type="text/javascript" src="ext/ajax.js"></script>
        <script type="text/javascript" src="ext/tlbMenu.js" />
        <script type="text/javascript">
            window.onload = initLeftMenu;
        </script>
        
        <script>
            var formMode = 0;
            function switchForms() {
                document.getElementById("loginDiv").style.display   = formMode==0?"none":"inline";
                document.getElementById("registerDiv").style.display = formMode==0?"inline":"none";
                formMode = formMode==0?1:0;
            }                    
            
            var unStat = 1;
            var psStat = 1;
            var mnStat = 1;
            
            function regSub(form) {
                if(unStat == 0 && psStat == 0 && mnStat == 0) {
                    form.submit();
                } else {
                document.getElementById("formStat").innerHTML = "Please correct form errors";
            }
        }
        
        
        function updateStat() {
            if(unStat == 0 && psStat == 0 && mnStat == 0) {
                document.getElementById("formStat").innerHTML = "";
            }
        }
        
        
        function checkUserName(form) {
            unStat = 1;
            updateStat();
            sendAjax("action=regCheckUserName&name=" + form.userName.value, checkUserNameCB);
        }
        
        function checkUserNameCB(respData) {
            if(respData.responseText.substring(0,1) == "1") {
                document.getElementById('userNameStatus').innerHTML = "available!";
                document.getElementById('userNameStatus').style.color="black";
                unStat = 0;
            } else {
            document.getElementById('userNameStatus').innerHTML = respData.responseText;
            document.getElementById('userNameStatus').style.color="red";
            unStat = 1;
        }
        updateStat();
    }
    
    function checkMoniker(form) {
        mnStat = 1;
        updateStat();
        sendAjax("action=regCheckMoniker&name=" + form.moniker.value, checkMonikerCB);
    }
    
    function checkMonikerCB(respData) {
        if(respData.responseText.substring(0,1) == "1") {
            document.getElementById('monikerStatus').innerHTML = "available!";
            document.getElementById('monikerStatus').style.color="black";
            mnStat = 0;
        } else {
        document.getElementById('monikerStatus').innerHTML = respData.responseText;
        document.getElementById('monikerStatus').style.color="red";
        mnStat = 1;
    }
    updateStat();
}

function checkPassword(form) {               
    if(form.password1.value == "" || form.password2.value == "") {
        document.getElementById('passwordStatus').innerHTML = "";
        psStat = 1;
        updateStat();
    } else if(form.password1.value != form.password2.value) {
    document.getElementById('passwordStatus').innerHTML = "passwords don't match";
    document.getElementById('passwordStatus').style.color="red";
    psStat = 1;
    updateStat();
} else {
psStat = 1;
updateStat();
sendAjax("action=regCheckPassword&name=" + form.password1.value, checkPasswordCB);
}
}

function checkPasswordCB(respData) {
    if(respData.responseText.substring(0,1) == "1") {
        document.getElementById('passwordStatus').innerHTML = "";
        psStat = 0;
    } else {
    document.getElementById('passwordStatus').innerHTML = respData.responseText;
    document.getElementById('passwordStatus').style.color="red";
    psStat = 1;
}
updateStat();
}


        </script>
        
    </head>
    
    <body onload="initLeftMenu()">
        <center>
            <div id="mainContainer">
                
                <table>
                        <td valign="top">
                                <%@ include file="header.jsp" %>
                                <br />
                            <div id="contentContainer" style="background-color:#FFFFFF">
                                <div id=loginDiv>
                                    <h1>Login</h1><a href="javascript: switchForms()"><span style="font-size:12px;">Register</span></a>
                                    <br /><br />
                                    <form action="loginAction.jsp" name="loginForm" method=post>
                                        <input type=hidden name=action value="<%= request.getParameter("action") %>">
                                        <input type=hidden name=threadId value="<%= threadId %>">
                                        <input type=hidden name=postId value="<%= postId %>">
                                        <input type=hidden name=treeId value="<%= treeId %>">
                                        <input type=hidden name=x value="<%= x %>">
                                        <table width=500 border=0 cellpadding="2" cellspacing="1">
                                            <tr>
                                                <td width=80><b>Username:</b> </td>
                                                <td width=150><input type=text name=userName></td>
                                                <td><%= request.getAttribute("loginError") != null ? "<div class=errorText>Invalid username or password.</div>" : "" %></td>
                                            </tr>
                                            <tr>
                                                <td><b>Password:</b> </td>
                                                <td colspan="2"><input type=password name=password></td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                    <input type=submit class="btn" value="Login" id="loginButton">
                                                </td>
                                            </tr>
                                        </table>
                                    </form>
                                </div>
                                
                                
                                <div id=registerDiv style="display: none">
                                    <h1>Register <!--<span style="color: red">(Private Beta - By Invitation Only)</span>--></h1><a href="javascript: switchForms()"><span style="font-size:12px;">Login</span></a>
                                    <br />
                                    <form action="registerAction.jsp" name="regForm" method=post>
                                        <input type=hidden name=action value="<%= request.getParameter("action") %>">
                                        <input type=hidden name=threadId value="<%= threadId %>">
                                        <input type=hidden name=treeId value="<%= treeId %>">
                                        <input type=hidden name=postId value="<%= postId %>">
                                        <input type=hidden name=x value="<%= x %>">
                                        <table width=500 border=0 cellpadding="2" cellspacing="1">
                                            
                                            <tr>
                                                <td colspan="3">
                                                    <h3>Add a user for this site</h3>
                                                    <span style="color:#404040;font-size:13px">This login name is never shown to others - use it to access the site and manage content from each of your monikers.</span>
                                                </td>
                                            </tr>
                                            <!--
                                        <tr>
                                            <td width=140><b>Private Beta Key:</b></td>
                                            <td colspan=2><input type=text name=key maxlength="45"></td>
                                        </tr>
-->
                                            <tr>
                                                <td width=140><b>Desired Username:</b></td>
                                                <td width=140><input type=text name=userName maxlength="12" onchange="checkUserName(this.form)"></td>
                                                <td><div id=userNameStatus>Required</div></td>
                                            </tr>
                                            <tr>
                                                <td><b>Password: </b></td>
                                                <td><input type=password name=password1 maxlength="12" onchange="checkPassword(this.form)"></td>
                                                <td><div id=passwordStatus>Required</div></td>
                                            </tr>
                                            <tr>
                                                <td><b>Re-Enter Password: </b></td>
                                                <td colspan="2"><input type=password name=password2 maxlength="12" onchange="checkPassword(this.form)"></td>
                                            </tr>
                                            <tr>
                                                <td valign=top><b>Reply/Edit Style: </b></td>
                                                <td colspan="2"><input checked type=radio name=inlineReply value=1>Inline (recommended)<br><input type=radio name=inlineReply value=0>Classic</td>
                                            </tr>
                                            
                                            
                                            <tr>
                                                <td colspan="3">
                                                    <br />
                                                    <h3>Add your primary moniker</h3>
                                                    <span style="color:#404040;font-size:13px">This is what others will see when you create content on the site.  You can add more monikers later.</span>
                                                </td>
                                            </tr>
                                            
                                            <tr>
                                                <td width=140><b>Moniker:</b></td>
                                                <td width=140><input type=text name=moniker maxlength="45" onchange="checkMoniker(this.form)"></td>
                                                <td><div id=monikerStatus>Required</div></td>
                                            </tr>
                                            <tr>
                                                <td><b>Tagline: </b></td>
                                                <td><input type=text name=tag maxlength="45"></td>
                                                <td align="left"><i>optional</i></td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                    <br />
                                                    <h3>Content Filter Settings</h3>
                                                    <span style="color:#404040;font-size:13px">Please read about our <a href="policies.jsp" target=new>community moderation</a> program.  As a registered user you can opt-in to view flagged content.</span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan=3><input type=checkbox name=offensive value=1><b>Show Offensive Content - </b><span style="color:#404040;font-size:13px">(Content you wouldn't view at work or school.)</span></td>
                                            </tr>
                                            <tr>
                                                <td colspan=3><input type=checkbox name=spam value=1><b>Show Spam - </b><span style="color:#404040;font-size:13px">(Board cluttering content.)</span></td>
                                            </tr>
                                            
                                            <tr>
                                                <td colspan="3">
                                                    <br />
                                                    <hr noshade>
                                                    <span style="font-size:13px"><b>By clicking the 'register' button I declare that I have read and agree to the Big<%=Util.getUtil().getBoard(request) == Util.BCB ? "College" : "Law"%>Board.com <a href="policies.jsp" target=new>policies</a>.</b></span>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                    <br />
                                                    <input type=button class="btn" value="Register" id="registerButton" onclick="regSub(this.form)">
                                                    <br />
                                                    <div class="errorText" id="formStat"></div>
                                                </td>
                                            </tr>
                                            
                                            
                                        </table>
                                    </form>
                                </div>
                                
                            </div>
                        </td>
                        <td valign=top>
                            
                            <%@ include file="menu.jsp" %>
                            
                        </td>
                    </tr>
                </table>
                
                
            </div>
            <!-- Start of StatCounter Code -->
            <script type="text/javascript">
                var sc_project=2753481; 
                var sc_invisible=0; 
                var sc_partition=27; 
                var sc_security="fadeb289"; 
            </script>
            <script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a class="statcounter" href="http://www.statcounter.com/"><img class="statcounter" src="http://c28.statcounter.com/2753481/0/fadeb289/0/" alt="blog stats" /></a></div></noscript>
            <!-- End of StatCounter Code -->
        </center>
    </body>
</html>